<template>
  <div class="row-5">
    <div class="common-w-box">
      <div class="team-member">
        <div class="s1">
          <div class="cl">
            <img :src="memberData?.profileUrl" alt="" />
          </div>
          <div class="cr">
            <div class="f1">TEAM MEMBER</div>
            <div class="f2">团队成员</div>
            <div class="f3">
              <div class="tt">
                <div class="username">{{ memberData?.name || '' }}</div>
                <div class="tag">{{ memberData?.post || '' }}</div>
              </div>
              <div class="des" v-html="memberData?.text || ''"></div>
            </div>
          </div>
        </div>
        <div class="s2">
          <div class="cr">
            <div class="title-wrap">
              <h2>MERMBER</h2>
              <div class="trigger-wrap">
                <div class="btn prev" @click="onChangeMember('prev')">
                  <el-icon>
                    <ArrowLeft />
                  </el-icon>
                </div>
                <div class="btn next" @click="onChangeMember('next')">
                  <el-icon>
                    <ArrowRight />
                  </el-icon>
                </div>
              </div>
            </div>
            <div class="con">
              <el-carousel
                ref="remarkCarouselUp"
                height="auto"
                indicator-position="none"
                :autoplay="false"
                arrow="never"
              >
                <el-carousel-item
                  v-for="(item, i) in businessCardListAry"
                  :key="i"
                  style="height: 100px"
                >
                  <div class="member-wrap">
                    <div
                      class="member-item"
                      v-for="member in item"
                      :key="member.id"
                      @click="onChangeMemberData(member)"
                    >
                      <img :src="member.picUrl" />
                      <span>{{ member.name }}</span>
                    </div>
                  </div>
                </el-carousel-item>
              </el-carousel>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { reqGetBusinessCardList } from '@/api'
import { queryBusinessCardParams, respBusinessCardData } from '@/api/types'
import { CarouselInstance } from 'element-plus'
import { onMounted, ref } from 'vue'

// member模块切换
const remarkCarouselUp = ref<CarouselInstance>()
const onChangeMember = (type: string) => {
  if (type === 'prev') remarkCarouselUp.value!.prev()
  if (type === 'next') remarkCarouselUp.value!.next()
}

onMounted(() => {
  getBusinessCardList()
})

const memberData = ref<respBusinessCardData>()
const onChangeMemberData = async (member: respBusinessCardData) => {
  memberData.value = member
}

const businessCardListAry = ref<respBusinessCardData[][]>([[]])
const getBusinessCardList = async () => {
  const reqParams: queryBusinessCardParams = { pageNo: 1, pageSize: 12 }
  let list = await reqGetBusinessCardList(reqParams)
  if (list.data.list.length > 0) {
    businessCardListAry.value = [list.data.list]
    memberData.value = list.data.list[0]
  }
  let total = list.data.total
  if (total > 1) {
    for (let i = 2; i <= total; i++) {
      reqParams.pageNo = i
      list = await reqGetBusinessCardList(reqParams)
      businessCardListAry.value.push(list.data.list)
    }
  }
}
</script>
<style lang="scss" scoped>
.row-5 {
  padding-top: 70px;
  background: #fff;

  .team-member {
    .s1 {
      display: flex;

      .cl {
        width: 410px;
        text-align: center;
      }

      .cr {
        flex: 1;
        padding-left: 80px;

        .f1 {
          font-size: 24px;
          font-weight: 600;
          line-height: 28px;
          text-align: right;
        }

        .f2 {
          margin-top: 8px;
          font-size: 20px;
          font-weight: 600;
          line-height: 24px;
          color: #3aace3;
          text-align: right;
        }

        .f3 {
          .tt {
            margin-top: 37px;

            .username {
              font-size: 34px;
              color: $primary;
            }

            .tag {
              margin-top: 11px;
              font-size: 18px;
              font-weight: 600;
              color: #5f6085;
            }
          }

          .des {
            width: 760px;
            margin-top: 35px;
            font-weight: bold;
            line-height: 28px;
            color: #021429;
          }
        }
      }
    }

    .s2 {
      margin-top: -2px;

      .cr {
        display: flex;
        flex-direction: column;
        height: 190px;
        background: $primary;

        .title-wrap {
          display: flex;
          align-items: flex-end;
          justify-content: space-between;
          padding: 7px 12px 22px 22px;

          h2 {
            font-size: 50px;
            color: #fff;
          }

          .trigger-wrap {
            display: flex;
            align-items: center;

            .btn {
              display: flex;
              align-items: center;
              justify-content: center;
              width: 32px;
              height: 32px;
              font-size: 15px;
              color: $primary;
              cursor: pointer;
              background-color: #fff;
              border-radius: 50%;

              & + .btn {
                margin-left: 26px;
              }
            }
          }
        }

        .con {
          flex: 1;

          .member-wrap {
            display: flex;
            align-items: center;
            padding: 0 28px;

            .member-item {
              display: flex;
              flex-direction: column;
              align-items: center;
              margin: 0 12px;

              img {
                width: 60px;
                height: 60px;
                margin-bottom: 10px;
                background-color: #eee;
                border-radius: 50%;
              }

              span {
                font-size: 14px;
                color: #fff;
              }
            }
          }
        }
      }
    }
  }
}
</style>
